package reflection;

import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;

//通过反射获取获取泛型
public class Test07 {
    public static void main(String[] args) throws NoSuchMethodException {
        Method method = Test07.class.getMethod("test01", Map.class, List.class);
        Type[] parameterTypes = method.getParameterTypes();

        for (Type type : parameterTypes) {
            System.out.println("#" + type);
            if (type instanceof ParameterizedType) {
                Type[] actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments();
                for (Type t : actualTypeArguments) {
                    System.out.println(t);
                }

            }
        }
    }

    public void test01(Map<String, User> map, List<User> list) {
        System.out.println("test01");
    }

    public Map<String, User> test02() {
        System.out.println("test02");
        return null;
    }
}
